import React from 'react'
import {render} from 'react-dom'
import VConsole from 'vconsole'
import './assets/styles/index.scss'
import App from './view/App'
import {Provider} from "react-redux";
import store from './store/index'
// import {windowUtil} from "./basic/utils/windowUtil";
import moment from "moment";

moment.locale('zh-cn');


const root = document.getElementById('root')
// const vConsole = new VConsole();
let app = () => (
    <div className='themes-warp theme-light'>
        <Provider store={store}>
            <App/>
        </Provider>
    </div>
)
// window.alertMsg = (str) => {
//     windowUtil.alertMsg(str)
// }
window.onerror = (msg, url, l) => {
    if (msg == 'ResizeObserver loop limit exceeded') return;
    // console.error(msg,url,l)
    let msgNew = msg.substr(msg.indexOf(': ') + 2);
    if (msgNew.indexOf('_') != 0) {
        alertMsg(msgNew);
    }
    return false;
}

// let onPluginReadyCallbackList = [];
// window.onPluginReady = (fun) => {
//     onPluginReadyCallbackList.push(fun);
// }
// window.utools.onPluginReady(() => {
//     onPluginReadyCallbackList.forEach(fun => fun())
// })

window.onPluginEnterCallbackList = [];
window.onPluginEnter = (fun) => {
    window.onPluginEnterCallbackList.push(fun);
}
window.utools.onPluginEnter(() => {
    window.onPluginEnterCallbackList.forEach(fun => fun())
})



render(app(), root);

//状态改变，更新UI
// store.subscribe(() => {
//     render(app(), root);
// })
